package thread;

public class ThreadDemo13 {
    public static void main(String[] args) throws InterruptedException{
        Thread thread = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    break;
                }
            }
        });
        //启动之前获取thread的状态，就是NEW状态
        System.out.println("start之前:" + thread.getState());

        thread.start();
        for (int i = 0; i < 1000; i++) {
            System.out.println("执行中的状态：" + thread.getState());
        }

        thread.join();

        //执行结束之后，就是 TERMINATED状态
        System.out.println("thread 结束之后：" + thread.getState());
    }
}

